package leetcode_301_400;

public class LeeCode_374 {

    public static void main(String[] args) {
        System.out.println(guessNumber(8));
    }

    static int pick = 6;

    private static int guessNumber(int n) {
        int l = 1, r = n;
        while (l < r){
            int m = (l + r) >>> 1;
            if (guess(m) <= 0){
                r = m;
            }else {
                l = m + 1;
            }
        }
        return l;
    }
    private static int guess(int n){
        return Integer.compare(n, pick);
    }
}
